Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

305
Vistas
React to "click event" in Python (Django)

everyone, beforehand - I'm a bloody but motivated developer beginner.

I am currently trying to react to simple events (click on a button) in the HTML code in my Django project. Unfortunately without success ...

HTML:

<form>
    {% csrf_token %}
    <button id="CSVDownload" type="button">CSV Download!</button>
</form>

JavaScript:

    <script>
        document.addEventListener("DOMContentLoaded", () => {
            const CSVDownload = document.querySelector("#CSVDownload")
            CSVDownload.addEventListener("click", () => {
                console.dir("Test")
            })
        })
    </script>

Do I need JavaScript for this? Or is there a way to react directly to such events in python (Django)?

I am really grateful for all the support.

Since I'm not really "good" yet - a simple solution would be great :)

Python (Django)

    if request.method == "POST":
        projectName = request.POST["projectName"]
        rootDomain = request.POST["rootDomain"]
        startURL = request.POST["startURL"]
....

With this, for example, I managed to react to a kind of event, i.e. when the user sends the form. The problem here, however, is - if I have several forms on one page, then I cannot distinguish which function should be carried out: / I am at a loss

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This World help you HTML

<form>
    {% csrf_token %}
    <button id="CSVDownload" type="button" onclick="download_csv()">CSV Download!</button>
</form>

Javascript

<script>
       function download_csv{
        document.addEventListener("DOMContentLoaded", () => {
        const CSVDownload = document.querySelector("#CSVDownload")
        CSVDownload.addEventListener("click", () => {
            console.dir("Test")
        })
    })

 }
    
</script>

It might be error while writing the function but this is the way how you react by javascript to the click using on click method

about 4 years ago · Juan Pablo Isaza Denunciar

0

Do I need JavaScript for this? Or is there a way to react directly to such events in python (Django)?

I would say that for now JavaScript is the best avenue for you to explore, as whilst there are various ways of getting python to run on the client side (i.e. in your browser), I wouldn't necessarily recommend them to a beginner. Or rather, interpolating them into a Django project might be challenging.

Skulpt

Brython

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda